package androidx.recyclerview.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import androidx.recyclerview.widget.RecyclerView;
import b.f.l.b0.c;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.List;

public class StaggeredGridLayoutManager extends RecyclerView.o implements RecyclerView.z.b {
    boolean A = false;
    private BitSet B;
    int C = -1;
    int D = RecyclerView.UNDEFINED_DURATION;
    d E = new d();
    private int F = 2;
    private boolean G;
    private boolean H;
    private e I;
    private int J;
    private final Rect K = new Rect();
    private final b L = new b();
    private boolean M = false;
    private boolean N = true;
    private int[] O;
    private final Runnable P = new a();
    private int s = -1;
    f[] t;
    n u;
    n v;
    private int w;
    private int x;
    private final i y;
    boolean z = false;

    class a implements Runnable {
        a() {
        }

        public void run() {
            StaggeredGridLayoutManager.this.S1();
        }
    }

    class b {

        /* renamed from: a  reason: collision with root package name */
        int f913a;

        /* renamed from: b  reason: collision with root package name */
        int f914b;

        /* renamed from: c  reason: collision with root package name */
        boolean f915c;

        /* renamed from: d  reason: collision with root package name */
        boolean f916d;
        boolean e;
        int[] f;

        b() {
            c();
        }

        /* access modifiers changed from: package-private */
        public void a() {
            this.f914b = this.f915c ? StaggeredGridLayoutManager.this.u.i() : StaggeredGridLayoutManager.this.u.m();
        }

        /* access modifiers changed from: package-private */
        public void b(int i) {
            this.f914b = this.f915c ? StaggeredGridLayoutManager.this.u.i() - i : StaggeredGridLayoutManager.this.u.m() + i;
        }

        /* access modifiers changed from: package-private */
        public void c() {
            this.f913a = -1;
            this.f914b = RecyclerView.UNDEFINED_DURATION;
            this.f915c = false;
            this.f916d = false;
            this.e = false;
            int[] iArr = this.f;
            if (iArr != null) {
                Arrays.fill(iArr, -1);
            }
        }

        /* access modifiers changed from: package-private */
        public void d(f[] fVarArr) {
            int length = fVarArr.length;
            int[] iArr = this.f;
            if (iArr == null || iArr.length < length) {
                this.f = new int[StaggeredGridLayoutManager.this.t.length];
            }
            for (int i = 0; i < length; i++) {
                this.f[i] = fVarArr[i].p(RecyclerView.UNDEFINED_DURATION);
            }
        }
    }

    public static class c extends RecyclerView.p {
        f e;
        boolean f;

        public c(int i, int i2) {
            super(i, i2);
        }

        public c(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
        }

        public c(ViewGroup.LayoutParams layoutParams) {
            super(layoutParams);
        }

        public c(ViewGroup.MarginLayoutParams marginLayoutParams) {
            super(marginLayoutParams);
        }

        public final int e() {
            f fVar = this.e;
            if (fVar == null) {
                return -1;
            }
            return fVar.e;
        }

        public boolean f() {
            return this.f;
        }
    }

    static class d {

        /* renamed from: a  reason: collision with root package name */
        int[] f917a;

        /* renamed from: b  reason: collision with root package name */
        List<a> f918b;

        @SuppressLint({"BanParcelableUsage"})
        static class a implements Parcelable {
            public static final Parcelable.Creator<a> CREATOR = new C0023a();

            /* renamed from: b  reason: collision with root package name */
            int f919b;

            /* renamed from: c  reason: collision with root package name */
            int f920c;

            /* renamed from: d  reason: collision with root package name */
            int[] f921d;
            boolean e;

            /* renamed from: androidx.recyclerview.widget.StaggeredGridLayoutManager$d$a$a  reason: collision with other inner class name */
            static class C0023a implements Parcelable.Creator<a> {
                C0023a() {
                }

                /* renamed from: a */
                public a createFromParcel(Parcel parcel) {
                    return new a(parcel);
                }

                /* renamed from: b */
                public a[] newArray(int i) {
                    return new a[i];
                }
            }

            a() {
            }

            a(Parcel parcel) {
                this.f919b = parcel.readInt();
                this.f920c = parcel.readInt();
                this.e = parcel.readInt() != 1 ? false : true;
                int readInt = parcel.readInt();
                if (readInt > 0) {
                    int[] iArr = new int[readInt];
                    this.f921d = iArr;
                    parcel.readIntArray(iArr);
                }
            }

            public int describeContents() {
                return 0;
            }

            /* access modifiers changed from: package-private */
            public int j(int i) {
                int[] iArr = this.f921d;
                if (iArr == null) {
                    return 0;
                }
                return iArr[i];
            }

            public String toString() {
                return "FullSpanItem{mPosition=" + this.f919b + ", mGapDir=" + this.f920c + ", mHasUnwantedGapAfter=" + this.e + ", mGapPerSpan=" + Arrays.toString(this.f921d) + '}';
            }

            public void writeToParcel(Parcel parcel, int i) {
                parcel.writeInt(this.f919b);
                parcel.writeInt(this.f920c);
                parcel.writeInt(this.e ? 1 : 0);
                int[] iArr = this.f921d;
                if (iArr == null || iArr.length <= 0) {
                    parcel.writeInt(0);
                    return;
                }
                parcel.writeInt(iArr.length);
                parcel.writeIntArray(this.f921d);
            }
        }

        d() {
        }

        private int i(int i) {
            if (this.f918b == null) {
                return -1;
            }
            a f = f(i);
            if (f != null) {
                this.f918b.remove(f);
            }
            int size = this.f918b.size();
            int i2 = 0;
            while (true) {
                if (i2 >= size) {
                    i2 = -1;
                    break;
                } else if (this.f918b.get(i2).f919b >= i) {
                    break;
                } else {
                    i2++;
                }
            }
            if (i2 == -1) {
                return -1;
            }
            this.f918b.remove(i2);
            return this.f918b.get(i2).f919b;
        }

        private void l(int i, int i2) {
            List<a> list = this.f918b;
            if (list != null) {
                for (int size = list.size() - 1; size >= 0; size--) {
                    a aVar = this.f918b.get(size);
                    int i3 = aVar.f919b;
                    if (i3 >= i) {
                        aVar.f919b = i3 + i2;
                    }
                }
            }
        }

        private void m(int i, int i2) {
            List<a> list = this.f918b;
            if (list != null) {
                int i3 = i + i2;
                for (int size = list.size() - 1; size >= 0; size--) {
                    a aVar = this.f918b.get(size);
                    int i4 = aVar.f919b;
                    if (i4 >= i) {
                        if (i4 < i3) {
                            this.f918b.remove(size);
                        } else {
                            aVar.f919b = i4 - i2;
                        }
                    }
                }
            }
        }

        public void a(a aVar) {
            if (this.f918b == null) {
                this.f918b = new ArrayList();
            }
            int size = this.f918b.size();
            for (int i = 0; i < size; i++) {
                a aVar2 = this.f918b.get(i);
                if (aVar2.f919b == aVar.f919b) {
                    this.f918b.remove(i);
                }
                if (aVar2.f919b >= aVar.f919b) {
                    this.f918b.add(i, aVar);
                    return;
                }
            }
            this.f918b.add(aVar);
        }

        /* access modifiers changed from: package-private */
        public void b() {
            int[] iArr = this.f917a;
            if (iArr != null) {
                Arrays.fill(iArr, -1);
            }
            this.f918b = null;
        }

        /* access modifiers changed from: package-private */
        public void c(int i) {
            int[] iArr = this.f917a;
            if (iArr == null) {
                int[] iArr2 = new int[(Math.max(i, 10) + 1)];
                this.f917a = iArr2;
                Arrays.fill(iArr2, -1);
            } else if (i >= iArr.length) {
                int[] iArr3 = new int[o(i)];
                this.f917a = iArr3;
                System.arraycopy(iArr, 0, iArr3, 0, iArr.length);
                int[] iArr4 = this.f917a;
                Arrays.fill(iArr4, iArr.length, iArr4.length, -1);
            }
        }

        /* access modifiers changed from: package-private */
        public int d(int i) {
            List<a> list = this.f918b;
            if (list != null) {
                for (int size = list.size() - 1; size >= 0; size--) {
                    if (this.f918b.get(size).f919b >= i) {
                        this.f918b.remove(size);
                    }
                }
            }
            return h(i);
        }

        public a e(int i, int i2, int i3, boolean z) {
            List<a> list = this.f918b;
            if (list == null) {
                return null;
            }
            int size = list.size();
            for (int i4 = 0; i4 < size; i4++) {
                a aVar = this.f918b.get(i4);
                int i5 = aVar.f919b;
                if (i5 >= i2) {
                    return null;
                }
                if (i5 >= i && (i3 == 0 || aVar.f920c == i3 || (z && aVar.e))) {
                    return aVar;
                }
            }
            return null;
        }

        public a f(int i) {
            List<a> list = this.f918b;
            if (list == null) {
                return null;
            }
            for (int size = list.size() - 1; size >= 0; size--) {
                a aVar = this.f918b.get(size);
                if (aVar.f919b == i) {
                    return aVar;
                }
            }
            return null;
        }

        /* access modifiers changed from: package-private */
        public int g(int i) {
            int[] iArr = this.f917a;
            if (iArr == null || i >= iArr.length) {
                return -1;
            }
            return iArr[i];
        }

        /* access modifiers changed from: package-private */
        public int h(int i) {
            int[] iArr = this.f917a;
            if (iArr == null || i >= iArr.length) {
                return -1;
            }
            int i2 = i(i);
            if (i2 == -1) {
                int[] iArr2 = this.f917a;
                Arrays.fill(iArr2, i, iArr2.length, -1);
                return this.f917a.length;
            }
            int i3 = i2 + 1;
            Arrays.fill(this.f917a, i, i3, -1);
            return i3;
        }

        /* access modifiers changed from: package-private */
        public void j(int i, int i2) {
            int[] iArr = this.f917a;
            if (iArr != null && i < iArr.length) {
                int i3 = i + i2;
                c(i3);
                int[] iArr2 = this.f917a;
                System.arraycopy(iArr2, i, iArr2, i3, (iArr2.length - i) - i2);
                Arrays.fill(this.f917a, i, i3, -1);
                l(i, i2);
            }
        }

        /* access modifiers changed from: package-private */
        public void k(int i, int i2) {
            int[] iArr = this.f917a;
            if (iArr != null && i < iArr.length) {
                int i3 = i + i2;
                c(i3);
                int[] iArr2 = this.f917a;
                System.arraycopy(iArr2, i3, iArr2, i, (iArr2.length - i) - i2);
                int[] iArr3 = this.f917a;
                Arrays.fill(iArr3, iArr3.length - i2, iArr3.length, -1);
                m(i, i2);
            }
        }

        /* access modifiers changed from: package-private */
        public void n(int i, f fVar) {
            c(i);
            this.f917a[i] = fVar.e;
        }

        /* access modifiers changed from: package-private */
        public int o(int i) {
            int length = this.f917a.length;
            while (length <= i) {
                length *= 2;
            }
            return length;
        }
    }

    @SuppressLint({"BanParcelableUsage"})
    public static class e implements Parcelable {
        public static final Parcelable.Creator<e> CREATOR = new a();

        /* renamed from: b  reason: collision with root package name */
        int f922b;

        /* renamed from: c  reason: collision with root package name */
        int f923c;

        /* renamed from: d  reason: collision with root package name */
        int f924d;
        int[] e;
        int f;
        int[] g;
        List<d.a> h;
        boolean i;
        boolean j;
        boolean k;

        static class a implements Parcelable.Creator<e> {
            a() {
            }

            /* renamed from: a */
            public e createFromParcel(Parcel parcel) {
                return new e(parcel);
            }

            /* renamed from: b */
            public e[] newArray(int i) {
                return new e[i];
            }
        }

        public e() {
        }

        e(Parcel parcel) {
            this.f922b = parcel.readInt();
            this.f923c = parcel.readInt();
            int readInt = parcel.readInt();
            this.f924d = readInt;
            if (readInt > 0) {
                int[] iArr = new int[readInt];
                this.e = iArr;
                parcel.readIntArray(iArr);
            }
            int readInt2 = parcel.readInt();
            this.f = readInt2;
            if (readInt2 > 0) {
                int[] iArr2 = new int[readInt2];
                this.g = iArr2;
                parcel.readIntArray(iArr2);
            }
            boolean z = false;
            this.i = parcel.readInt() == 1;
            this.j = parcel.readInt() == 1;
            this.k = parcel.readInt() == 1 ? true : z;
            this.h = parcel.readArrayList(d.a.class.getClassLoader());
        }

        public e(e eVar) {
            this.f924d = eVar.f924d;
            this.f922b = eVar.f922b;
            this.f923c = eVar.f923c;
            this.e = eVar.e;
            this.f = eVar.f;
            this.g = eVar.g;
            this.i = eVar.i;
            this.j = eVar.j;
            this.k = eVar.k;
            this.h = eVar.h;
        }

        public int describeContents() {
            return 0;
        }

        /* access modifiers changed from: package-private */
        public void j() {
            this.e = null;
            this.f924d = 0;
            this.f922b = -1;
            this.f923c = -1;
        }

        /* access modifiers changed from: package-private */
        public void k() {
            this.e = null;
            this.f924d = 0;
            this.f = 0;
            this.g = null;
            this.h = null;
        }

        public void writeToParcel(Parcel parcel, int i2) {
            parcel.writeInt(this.f922b);
            parcel.writeInt(this.f923c);
            parcel.writeInt(this.f924d);
            if (this.f924d > 0) {
                parcel.writeIntArray(this.e);
            }
            parcel.writeInt(this.f);
            if (this.f > 0) {
                parcel.writeIntArray(this.g);
            }
            parcel.writeInt(this.i ? 1 : 0);
            parcel.writeInt(this.j ? 1 : 0);
            parcel.writeInt(this.k ? 1 : 0);
            parcel.writeList(this.h);
        }
    }

    class f {

        /* renamed from: a  reason: collision with root package name */
        ArrayList<View> f925a = new ArrayList<>();

        /* renamed from: b  reason: collision with root package name */
        int f926b = RecyclerView.UNDEFINED_DURATION;

        /* renamed from: c  reason: collision with root package name */
        int f927c = RecyclerView.UNDEFINED_DURATION;

        /* renamed from: d  reason: collision with root package name */
        int f928d = 0;
        final int e;

        f(int i) {
            this.e = i;
        }

        /* access modifiers changed from: package-private */
        public void a(View view) {
            c n = n(view);
            n.e = this;
            this.f925a.add(view);
            this.f927c = RecyclerView.UNDEFINED_DURATION;
            if (this.f925a.size() == 1) {
                this.f926b = RecyclerView.UNDEFINED_DURATION;
            }
            if (n.c() || n.b()) {
                this.f928d += StaggeredGridLayoutManager.this.u.e(view);
            }
        }

        /* access modifiers changed from: package-private */
        public void b(boolean z, int i) {
            int l = z ? l(RecyclerView.UNDEFINED_DURATION) : p(RecyclerView.UNDEFINED_DURATION);
            e();
            if (l != Integer.MIN_VALUE) {
                if (z && l < StaggeredGridLayoutManager.this.u.i()) {
                    return;
                }
                if (z || l <= StaggeredGridLayoutManager.this.u.m()) {
                    if (i != Integer.MIN_VALUE) {
                        l += i;
                    }
                    this.f927c = l;
                    this.f926b = l;
                }
            }
        }

        /* access modifiers changed from: package-private */
        public void c() {
            d.a f2;
            ArrayList<View> arrayList = this.f925a;
            View view = arrayList.get(arrayList.size() - 1);
            c n = n(view);
            this.f927c = StaggeredGridLayoutManager.this.u.d(view);
            if (n.f && (f2 = StaggeredGridLayoutManager.this.E.f(n.a())) != null && f2.f920c == 1) {
                this.f927c += f2.j(this.e);
            }
        }

        /* access modifiers changed from: package-private */
        public void d() {
            d.a f2;
            View view = this.f925a.get(0);
            c n = n(view);
            this.f926b = StaggeredGridLayoutManager.this.u.g(view);
            if (n.f && (f2 = StaggeredGridLayoutManager.this.E.f(n.a())) != null && f2.f920c == -1) {
                this.f926b -= f2.j(this.e);
            }
        }

        /* access modifiers changed from: package-private */
        public void e() {
            this.f925a.clear();
            q();
            this.f928d = 0;
        }

        public int f() {
            int i;
            int i2;
            if (StaggeredGridLayoutManager.this.z) {
                i2 = this.f925a.size() - 1;
                i = -1;
            } else {
                i2 = 0;
                i = this.f925a.size();
            }
            return i(i2, i, true);
        }

        public int g() {
            int i;
            int i2;
            if (StaggeredGridLayoutManager.this.z) {
                i2 = 0;
                i = this.f925a.size();
            } else {
                i2 = this.f925a.size() - 1;
                i = -1;
            }
            return i(i2, i, true);
        }

        /* access modifiers changed from: package-private */
        public int h(int i, int i2, boolean z, boolean z2, boolean z3) {
            int m = StaggeredGridLayoutManager.this.u.m();
            int i3 = StaggeredGridLayoutManager.this.u.i();
            int i4 = i2 > i ? 1 : -1;
            while (i != i2) {
                View view = this.f925a.get(i);
                int g = StaggeredGridLayoutManager.this.u.g(view);
                int d2 = StaggeredGridLayoutManager.this.u.d(view);
                boolean z4 = false;
                boolean z5 = !z3 ? g < i3 : g <= i3;
                if (!z3 ? d2 > m : d2 >= m) {
                    z4 = true;
                }
                if (z5 && z4) {
                    if (!z || !z2) {
                        if (!z2 && g >= m && d2 <= i3) {
                        }
                    } else if (g >= m && d2 <= i3) {
                    }
                    return StaggeredGridLayoutManager.this.h0(view);
                }
                i += i4;
            }
            return -1;
        }

        /* access modifiers changed from: package-private */
        public int i(int i, int i2, boolean z) {
            return h(i, i2, false, false, z);
        }

        public int j() {
            return this.f928d;
        }

        /* access modifiers changed from: package-private */
        public int k() {
            int i = this.f927c;
            if (i != Integer.MIN_VALUE) {
                return i;
            }
            c();
            return this.f927c;
        }

        /* access modifiers changed from: package-private */
        public int l(int i) {
            int i2 = this.f927c;
            if (i2 != Integer.MIN_VALUE) {
                return i2;
            }
            if (this.f925a.size() == 0) {
                return i;
            }
            c();
            return this.f927c;
        }

        public View m(int i, int i2) {
            View view = null;
            if (i2 != -1) {
                int size = this.f925a.size() - 1;
                while (size >= 0) {
                    View view2 = this.f925a.get(size);
                    StaggeredGridLayoutManager staggeredGridLayoutManager = StaggeredGridLayoutManager.this;
                    if (staggeredGridLayoutManager.z && staggeredGridLayoutManager.h0(view2) >= i) {
                        break;
                    }
                    StaggeredGridLayoutManager staggeredGridLayoutManager2 = StaggeredGridLayoutManager.this;
                    if ((!staggeredGridLayoutManager2.z && staggeredGridLayoutManager2.h0(view2) <= i) || !view2.hasFocusable()) {
                        break;
                    }
                    size--;
                    view = view2;
                }
            } else {
                int size2 = this.f925a.size();
                int i3 = 0;
                while (i3 < size2) {
                    View view3 = this.f925a.get(i3);
                    StaggeredGridLayoutManager staggeredGridLayoutManager3 = StaggeredGridLayoutManager.this;
                    if (staggeredGridLayoutManager3.z && staggeredGridLayoutManager3.h0(view3) <= i) {
                        break;
                    }
                    StaggeredGridLayoutManager staggeredGridLayoutManager4 = StaggeredGridLayoutManager.this;
                    if ((!staggeredGridLayoutManager4.z && staggeredGridLayoutManager4.h0(view3) >= i) || !view3.hasFocusable()) {
                        break;
                    }
                    i3++;
                    view = view3;
                }
            }
            return view;
        }

        /* access modifiers changed from: package-private */
        public c n(View view) {
            return (c) view.getLayoutParams();
        }

        /* access modifiers changed from: package-private */
        public int o() {
            int i = this.f926b;
            if (i != Integer.MIN_VALUE) {
                return i;
            }
            d();
            return this.f926b;
        }

        /* access modifiers changed from: package-private */
        public int p(int i) {
            int i2 = this.f926b;
            if (i2 != Integer.MIN_VALUE) {
                return i2;
            }
            if (this.f925a.size() == 0) {
                return i;
            }
            d();
            return this.f926b;
        }

        /* access modifiers changed from: package-private */
        public void q() {
            this.f926b = RecyclerView.UNDEFINED_DURATION;
            this.f927c = RecyclerView.UNDEFINED_DURATION;
        }

        /* access modifiers changed from: package-private */
        public void r(int i) {
            int i2 = this.f926b;
            if (i2 != Integer.MIN_VALUE) {
                this.f926b = i2 + i;
            }
            int i3 = this.f927c;
            if (i3 != Integer.MIN_VALUE) {
                this.f927c = i3 + i;
            }
        }

        /* access modifiers changed from: package-private */
        public void s() {
            int size = this.f925a.size();
            View remove = this.f925a.remove(size - 1);
            c n = n(remove);
            n.e = null;
            if (n.c() || n.b()) {
                this.f928d -= StaggeredGridLayoutManager.this.u.e(remove);
            }
            if (size == 1) {
                this.f926b = RecyclerView.UNDEFINED_DURATION;
            }
            this.f927c = RecyclerView.UNDEFINED_DURATION;
        }

        /* access modifiers changed from: package-private */
        public void t() {
            View remove = this.f925a.remove(0);
            c n = n(remove);
            n.e = null;
            if (this.f925a.size() == 0) {
                this.f927c = RecyclerView.UNDEFINED_DURATION;
            }
            if (n.c() || n.b()) {
                this.f928d -= StaggeredGridLayoutManager.this.u.e(remove);
            }
            this.f926b = RecyclerView.UNDEFINED_DURATION;
        }

        /* access modifiers changed from: package-private */
        public void u(View view) {
            c n = n(view);
            n.e = this;
            this.f925a.add(0, view);
            this.f926b = RecyclerView.UNDEFINED_DURATION;
            if (this.f925a.size() == 1) {
                this.f927c = RecyclerView.UNDEFINED_DURATION;
            }
            if (n.c() || n.b()) {
                this.f928d += StaggeredGridLayoutManager.this.u.e(view);
            }
        }

        /* access modifiers changed from: package-private */
        public void v(int i) {
            this.f926b = i;
            this.f927c = i;
        }
    }

    public StaggeredGridLayoutManager(Context context, AttributeSet attributeSet, int i, int i2) {
        RecyclerView.o.d i0 = RecyclerView.o.i0(context, attributeSet, i, i2);
        H2(i0.f884a);
        J2(i0.f885b);
        I2(i0.f886c);
        this.y = new i();
        a2();
    }

    /* JADX WARNING: Code restructure failed: missing block: B:7:0x0010, code lost:
        if (r4.e == -1) goto L_0x0012;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void A2(androidx.recyclerview.widget.RecyclerView.v r3, androidx.recyclerview.widget.i r4) {
        /*
            r2 = this;
            boolean r0 = r4.f1017a
            if (r0 == 0) goto L_0x004d
            boolean r0 = r4.i
            if (r0 == 0) goto L_0x0009
            goto L_0x004d
        L_0x0009:
            int r0 = r4.f1018b
            r1 = -1
            if (r0 != 0) goto L_0x001e
            int r0 = r4.e
            if (r0 != r1) goto L_0x0018
        L_0x0012:
            int r4 = r4.g
        L_0x0014:
            r2.B2(r3, r4)
            goto L_0x004d
        L_0x0018:
            int r4 = r4.f
        L_0x001a:
            r2.C2(r3, r4)
            goto L_0x004d
        L_0x001e:
            int r0 = r4.e
            if (r0 != r1) goto L_0x0037
            int r0 = r4.f
            int r1 = r2.m2(r0)
            int r0 = r0 - r1
            if (r0 >= 0) goto L_0x002c
            goto L_0x0012
        L_0x002c:
            int r1 = r4.g
            int r4 = r4.f1018b
            int r4 = java.lang.Math.min(r0, r4)
            int r4 = r1 - r4
            goto L_0x0014
        L_0x0037:
            int r0 = r4.g
            int r0 = r2.n2(r0)
            int r1 = r4.g
            int r0 = r0 - r1
            if (r0 >= 0) goto L_0x0043
            goto L_0x0018
        L_0x0043:
            int r1 = r4.f
            int r4 = r4.f1018b
            int r4 = java.lang.Math.min(r0, r4)
            int r4 = r4 + r1
            goto L_0x001a
        L_0x004d:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.StaggeredGridLayoutManager.A2(androidx.recyclerview.widget.RecyclerView$v, androidx.recyclerview.widget.i):void");
    }

    private void B2(RecyclerView.v vVar, int i) {
        int J2 = J() - 1;
        while (J2 >= 0) {
            View I2 = I(J2);
            if (this.u.g(I2) >= i && this.u.q(I2) >= i) {
                c cVar = (c) I2.getLayoutParams();
                if (cVar.f) {
                    int i2 = 0;
                    while (i2 < this.s) {
                        if (this.t[i2].f925a.size() != 1) {
                            i2++;
                        } else {
                            return;
                        }
                    }
                    for (int i3 = 0; i3 < this.s; i3++) {
                        this.t[i3].s();
                    }
                } else if (cVar.e.f925a.size() != 1) {
                    cVar.e.s();
                } else {
                    return;
                }
                m1(I2, vVar);
                J2--;
            } else {
                return;
            }
        }
    }

    private void C2(RecyclerView.v vVar, int i) {
        while (J() > 0) {
            View I2 = I(0);
            if (this.u.d(I2) <= i && this.u.p(I2) <= i) {
                c cVar = (c) I2.getLayoutParams();
                if (cVar.f) {
                    int i2 = 0;
                    while (i2 < this.s) {
                        if (this.t[i2].f925a.size() != 1) {
                            i2++;
                        } else {
                            return;
                        }
                    }
                    for (int i3 = 0; i3 < this.s; i3++) {
                        this.t[i3].t();
                    }
                } else if (cVar.e.f925a.size() != 1) {
                    cVar.e.t();
                } else {
                    return;
                }
                m1(I2, vVar);
            } else {
                return;
            }
        }
    }

    private void D2() {
        if (this.v.k() != 1073741824) {
            float f2 = 0.0f;
            int J2 = J();
            for (int i = 0; i < J2; i++) {
                View I2 = I(i);
                float e2 = (float) this.v.e(I2);
                if (e2 >= f2) {
                    if (((c) I2.getLayoutParams()).f()) {
                        e2 = (e2 * 1.0f) / ((float) this.s);
                    }
                    f2 = Math.max(f2, e2);
                }
            }
            int i2 = this.x;
            int round = Math.round(f2 * ((float) this.s));
            if (this.v.k() == Integer.MIN_VALUE) {
                round = Math.min(round, this.v.n());
            }
            P2(round);
            if (this.x != i2) {
                for (int i3 = 0; i3 < J2; i3++) {
                    View I3 = I(i3);
                    c cVar = (c) I3.getLayoutParams();
                    if (!cVar.f) {
                        if (!t2() || this.w != 1) {
                            int i4 = cVar.e.e;
                            int i5 = this.w;
                            int i6 = (this.x * i4) - (i4 * i2);
                            if (i5 == 1) {
                                I3.offsetLeftAndRight(i6);
                            } else {
                                I3.offsetTopAndBottom(i6);
                            }
                        } else {
                            int i7 = this.s;
                            int i8 = cVar.e.e;
                            I3.offsetLeftAndRight(((-((i7 - 1) - i8)) * this.x) - ((-((i7 - 1) - i8)) * i2));
                        }
                    }
                }
            }
        }
    }

    private void E2() {
        this.A = (this.w == 1 || !t2()) ? this.z : !this.z;
    }

    private void G2(int i) {
        i iVar = this.y;
        iVar.e = i;
        int i2 = 1;
        if (this.A != (i == -1)) {
            i2 = -1;
        }
        iVar.f1020d = i2;
    }

    private void K2(int i, int i2) {
        for (int i3 = 0; i3 < this.s; i3++) {
            if (!this.t[i3].f925a.isEmpty()) {
                Q2(this.t[i3], i, i2);
            }
        }
    }

    private boolean L2(RecyclerView.a0 a0Var, b bVar) {
        boolean z2 = this.G;
        int b2 = a0Var.b();
        bVar.f913a = z2 ? g2(b2) : c2(b2);
        bVar.f914b = RecyclerView.UNDEFINED_DURATION;
        return true;
    }

    private void M1(View view) {
        for (int i = this.s - 1; i >= 0; i--) {
            this.t[i].a(view);
        }
    }

    private void N1(b bVar) {
        boolean z2;
        e eVar = this.I;
        int i = eVar.f924d;
        if (i > 0) {
            if (i == this.s) {
                for (int i2 = 0; i2 < this.s; i2++) {
                    this.t[i2].e();
                    e eVar2 = this.I;
                    int i3 = eVar2.e[i2];
                    if (i3 != Integer.MIN_VALUE) {
                        i3 += eVar2.j ? this.u.i() : this.u.m();
                    }
                    this.t[i2].v(i3);
                }
            } else {
                eVar.k();
                e eVar3 = this.I;
                eVar3.f922b = eVar3.f923c;
            }
        }
        e eVar4 = this.I;
        this.H = eVar4.k;
        I2(eVar4.i);
        E2();
        e eVar5 = this.I;
        int i4 = eVar5.f922b;
        if (i4 != -1) {
            this.C = i4;
            z2 = eVar5.j;
        } else {
            z2 = this.A;
        }
        bVar.f915c = z2;
        e eVar6 = this.I;
        if (eVar6.f > 1) {
            d dVar = this.E;
            dVar.f917a = eVar6.g;
            dVar.f918b = eVar6.h;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:15:0x0036  */
    /* JADX WARNING: Removed duplicated region for block: B:16:0x004d  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void O2(int r5, androidx.recyclerview.widget.RecyclerView.a0 r6) {
        /*
            r4 = this;
            androidx.recyclerview.widget.i r0 = r4.y
            r1 = 0
            r0.f1018b = r1
            r0.f1019c = r5
            boolean r0 = r4.x0()
            r2 = 1
            if (r0 == 0) goto L_0x002e
            int r6 = r6.c()
            r0 = -1
            if (r6 == r0) goto L_0x002e
            boolean r0 = r4.A
            if (r6 >= r5) goto L_0x001b
            r5 = 1
            goto L_0x001c
        L_0x001b:
            r5 = 0
        L_0x001c:
            if (r0 != r5) goto L_0x0025
            androidx.recyclerview.widget.n r5 = r4.u
            int r5 = r5.n()
            goto L_0x002f
        L_0x0025:
            androidx.recyclerview.widget.n r5 = r4.u
            int r5 = r5.n()
            r6 = r5
            r5 = 0
            goto L_0x0030
        L_0x002e:
            r5 = 0
        L_0x002f:
            r6 = 0
        L_0x0030:
            boolean r0 = r4.M()
            if (r0 == 0) goto L_0x004d
            androidx.recyclerview.widget.i r0 = r4.y
            androidx.recyclerview.widget.n r3 = r4.u
            int r3 = r3.m()
            int r3 = r3 - r6
            r0.f = r3
            androidx.recyclerview.widget.i r6 = r4.y
            androidx.recyclerview.widget.n r0 = r4.u
            int r0 = r0.i()
            int r0 = r0 + r5
            r6.g = r0
            goto L_0x005d
        L_0x004d:
            androidx.recyclerview.widget.i r0 = r4.y
            androidx.recyclerview.widget.n r3 = r4.u
            int r3 = r3.h()
            int r3 = r3 + r5
            r0.g = r3
            androidx.recyclerview.widget.i r5 = r4.y
            int r6 = -r6
            r5.f = r6
        L_0x005d:
            androidx.recyclerview.widget.i r5 = r4.y
            r5.h = r1
            r5.f1017a = r2
            androidx.recyclerview.widget.n r6 = r4.u
            int r6 = r6.k()
            if (r6 != 0) goto L_0x0074
            androidx.recyclerview.widget.n r6 = r4.u
            int r6 = r6.h()
            if (r6 != 0) goto L_0x0074
            r1 = 1
        L_0x0074:
            r5.i = r1
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.StaggeredGridLayoutManager.O2(int, androidx.recyclerview.widget.RecyclerView$a0):void");
    }

    private void Q1(View view, c cVar, i iVar) {
        if (iVar.e == 1) {
            if (cVar.f) {
                M1(view);
            } else {
                cVar.e.a(view);
            }
        } else if (cVar.f) {
            z2(view);
        } else {
            cVar.e.u(view);
        }
    }

    private void Q2(f fVar, int i, int i2) {
        int j = fVar.j();
        if (i == -1) {
            if (fVar.o() + j > i2) {
                return;
            }
        } else if (fVar.k() - j < i2) {
            return;
        }
        this.B.set(fVar.e, false);
    }

    private int R1(int i) {
        if (J() == 0) {
            return this.A ? 1 : -1;
        }
        return (i < j2()) != this.A ? -1 : 1;
    }

    private int R2(int i, int i2, int i3) {
        if (i2 == 0 && i3 == 0) {
            return i;
        }
        int mode = View.MeasureSpec.getMode(i);
        return (mode == Integer.MIN_VALUE || mode == 1073741824) ? View.MeasureSpec.makeMeasureSpec(Math.max(0, (View.MeasureSpec.getSize(i) - i2) - i3), mode) : i;
    }

    private boolean T1(f fVar) {
        if (this.A) {
            if (fVar.k() < this.u.i()) {
                ArrayList<View> arrayList = fVar.f925a;
                return !fVar.n(arrayList.get(arrayList.size() - 1)).f;
            }
        } else if (fVar.o() > this.u.m()) {
            return !fVar.n(fVar.f925a.get(0)).f;
        }
        return false;
    }

    private int U1(RecyclerView.a0 a0Var) {
        if (J() == 0) {
            return 0;
        }
        return p.a(a0Var, this.u, e2(!this.N), d2(!this.N), this, this.N);
    }

    private int V1(RecyclerView.a0 a0Var) {
        if (J() == 0) {
            return 0;
        }
        return p.b(a0Var, this.u, e2(!this.N), d2(!this.N), this, this.N, this.A);
    }

    private int W1(RecyclerView.a0 a0Var) {
        if (J() == 0) {
            return 0;
        }
        return p.c(a0Var, this.u, e2(!this.N), d2(!this.N), this, this.N);
    }

    private int X1(int i) {
        if (i == 1) {
            return (this.w != 1 && t2()) ? 1 : -1;
        }
        if (i == 2) {
            return (this.w != 1 && t2()) ? -1 : 1;
        }
        if (i != 17) {
            if (i != 33) {
                if (i != 66) {
                    if (i == 130 && this.w == 1) {
                        return 1;
                    }
                    return RecyclerView.UNDEFINED_DURATION;
                } else if (this.w == 0) {
                    return 1;
                } else {
                    return RecyclerView.UNDEFINED_DURATION;
                }
            } else if (this.w == 1) {
                return -1;
            } else {
                return RecyclerView.UNDEFINED_DURATION;
            }
        } else if (this.w == 0) {
            return -1;
        } else {
            return RecyclerView.UNDEFINED_DURATION;
        }
    }

    private d.a Y1(int i) {
        d.a aVar = new d.a();
        aVar.f921d = new int[this.s];
        for (int i2 = 0; i2 < this.s; i2++) {
            aVar.f921d[i2] = i - this.t[i2].l(i);
        }
        return aVar;
    }

    private d.a Z1(int i) {
        d.a aVar = new d.a();
        aVar.f921d = new int[this.s];
        for (int i2 = 0; i2 < this.s; i2++) {
            aVar.f921d[i2] = this.t[i2].p(i) - i;
        }
        return aVar;
    }

    private void a2() {
        this.u = n.b(this, this.w);
        this.v = n.b(this, 1 - this.w);
    }

    /* JADX WARNING: type inference failed for: r9v0 */
    /* JADX WARNING: type inference failed for: r9v1, types: [int, boolean] */
    /* JADX WARNING: type inference failed for: r9v5 */
    private int b2(RecyclerView.v vVar, i iVar, RecyclerView.a0 a0Var) {
        int i;
        f fVar;
        int i2;
        int i3;
        int i4;
        int i5;
        int i6;
        int i7;
        View view;
        StaggeredGridLayoutManager staggeredGridLayoutManager;
        RecyclerView.v vVar2 = vVar;
        i iVar2 = iVar;
        ? r9 = 0;
        this.B.set(0, this.s, true);
        if (this.y.i) {
            i = iVar2.e == 1 ? Integer.MAX_VALUE : RecyclerView.UNDEFINED_DURATION;
        } else {
            i = iVar2.e == 1 ? iVar2.g + iVar2.f1018b : iVar2.f - iVar2.f1018b;
        }
        K2(iVar2.e, i);
        int i8 = this.A ? this.u.i() : this.u.m();
        boolean z2 = false;
        while (iVar.a(a0Var) && (this.y.i || !this.B.isEmpty())) {
            View b2 = iVar2.b(vVar2);
            c cVar = (c) b2.getLayoutParams();
            int a2 = cVar.a();
            int g = this.E.g(a2);
            boolean z3 = g == -1;
            if (z3) {
                fVar = cVar.f ? this.t[r9] : p2(iVar2);
                this.E.n(a2, fVar);
            } else {
                fVar = this.t[g];
            }
            f fVar2 = fVar;
            cVar.e = fVar2;
            if (iVar2.e == 1) {
                d(b2);
            } else {
                e(b2, r9);
            }
            v2(b2, cVar, r9);
            if (iVar2.e == 1) {
                int l2 = cVar.f ? l2(i8) : fVar2.l(i8);
                int e2 = this.u.e(b2) + l2;
                if (z3 && cVar.f) {
                    d.a Y1 = Y1(l2);
                    Y1.f920c = -1;
                    Y1.f919b = a2;
                    this.E.a(Y1);
                }
                i2 = e2;
                i3 = l2;
            } else {
                int o2 = cVar.f ? o2(i8) : fVar2.p(i8);
                i3 = o2 - this.u.e(b2);
                if (z3 && cVar.f) {
                    d.a Z1 = Z1(o2);
                    Z1.f920c = 1;
                    Z1.f919b = a2;
                    this.E.a(Z1);
                }
                i2 = o2;
            }
            if (cVar.f && iVar2.f1020d == -1) {
                if (!z3) {
                    if (!(iVar2.e == 1 ? O1() : P1())) {
                        d.a f2 = this.E.f(a2);
                        if (f2 != null) {
                            f2.e = true;
                        }
                    }
                }
                this.M = true;
            }
            Q1(b2, cVar, iVar2);
            if (!t2() || this.w != 1) {
                int m = cVar.f ? this.v.m() : (fVar2.e * this.x) + this.v.m();
                i5 = m;
                i4 = this.v.e(b2) + m;
            } else {
                int i9 = cVar.f ? this.v.i() : this.v.i() - (((this.s - 1) - fVar2.e) * this.x);
                i4 = i9;
                i5 = i9 - this.v.e(b2);
            }
            if (this.w == 1) {
                staggeredGridLayoutManager = this;
                view = b2;
                i7 = i5;
                i5 = i3;
                i6 = i4;
            } else {
                staggeredGridLayoutManager = this;
                view = b2;
                i7 = i3;
                i6 = i2;
                i2 = i4;
            }
            staggeredGridLayoutManager.z0(view, i7, i5, i6, i2);
            if (cVar.f) {
                K2(this.y.e, i);
            } else {
                Q2(fVar2, this.y.e, i);
            }
            A2(vVar2, this.y);
            if (this.y.h && b2.hasFocusable()) {
                if (cVar.f) {
                    this.B.clear();
                } else {
                    this.B.set(fVar2.e, false);
                    z2 = true;
                    r9 = 0;
                }
            }
            z2 = true;
            r9 = 0;
        }
        if (!z2) {
            A2(vVar2, this.y);
        }
        int m2 = this.y.e == -1 ? this.u.m() - o2(this.u.m()) : l2(this.u.i()) - this.u.i();
        if (m2 > 0) {
            return Math.min(iVar2.f1018b, m2);
        }
        return 0;
    }

    private int c2(int i) {
        int J2 = J();
        for (int i2 = 0; i2 < J2; i2++) {
            int h0 = h0(I(i2));
            if (h0 >= 0 && h0 < i) {
                return h0;
            }
        }
        return 0;
    }

    private int g2(int i) {
        for (int J2 = J() - 1; J2 >= 0; J2--) {
            int h0 = h0(I(J2));
            if (h0 >= 0 && h0 < i) {
                return h0;
            }
        }
        return 0;
    }

    private void h2(RecyclerView.v vVar, RecyclerView.a0 a0Var, boolean z2) {
        int i;
        int l2 = l2(RecyclerView.UNDEFINED_DURATION);
        if (l2 != Integer.MIN_VALUE && (i = this.u.i() - l2) > 0) {
            int i2 = i - (-F2(-i, vVar, a0Var));
            if (z2 && i2 > 0) {
                this.u.r(i2);
            }
        }
    }

    private void i2(RecyclerView.v vVar, RecyclerView.a0 a0Var, boolean z2) {
        int m;
        int o2 = o2(Integer.MAX_VALUE);
        if (o2 != Integer.MAX_VALUE && (m = o2 - this.u.m()) > 0) {
            int F2 = m - F2(m, vVar, a0Var);
            if (z2 && F2 > 0) {
                this.u.r(-F2);
            }
        }
    }

    private int l2(int i) {
        int l = this.t[0].l(i);
        for (int i2 = 1; i2 < this.s; i2++) {
            int l2 = this.t[i2].l(i);
            if (l2 > l) {
                l = l2;
            }
        }
        return l;
    }

    private int m2(int i) {
        int p = this.t[0].p(i);
        for (int i2 = 1; i2 < this.s; i2++) {
            int p2 = this.t[i2].p(i);
            if (p2 > p) {
                p = p2;
            }
        }
        return p;
    }

    private int n2(int i) {
        int l = this.t[0].l(i);
        for (int i2 = 1; i2 < this.s; i2++) {
            int l2 = this.t[i2].l(i);
            if (l2 < l) {
                l = l2;
            }
        }
        return l;
    }

    private int o2(int i) {
        int p = this.t[0].p(i);
        for (int i2 = 1; i2 < this.s; i2++) {
            int p2 = this.t[i2].p(i);
            if (p2 < p) {
                p = p2;
            }
        }
        return p;
    }

    private f p2(i iVar) {
        int i;
        int i2;
        int i3 = -1;
        if (x2(iVar.e)) {
            i2 = this.s - 1;
            i = -1;
        } else {
            i2 = 0;
            i3 = this.s;
            i = 1;
        }
        f fVar = null;
        if (iVar.e == 1) {
            int i4 = Integer.MAX_VALUE;
            int m = this.u.m();
            while (i2 != i3) {
                f fVar2 = this.t[i2];
                int l = fVar2.l(m);
                if (l < i4) {
                    fVar = fVar2;
                    i4 = l;
                }
                i2 += i;
            }
            return fVar;
        }
        int i5 = RecyclerView.UNDEFINED_DURATION;
        int i6 = this.u.i();
        while (i2 != i3) {
            f fVar3 = this.t[i2];
            int p = fVar3.p(i6);
            if (p > i5) {
                fVar = fVar3;
                i5 = p;
            }
            i2 += i;
        }
        return fVar;
    }

    /* JADX WARNING: Removed duplicated region for block: B:13:0x0025  */
    /* JADX WARNING: Removed duplicated region for block: B:18:0x003c  */
    /* JADX WARNING: Removed duplicated region for block: B:20:0x0043 A[RETURN] */
    /* JADX WARNING: Removed duplicated region for block: B:21:0x0044  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void q2(int r7, int r8, int r9) {
        /*
            r6 = this;
            boolean r0 = r6.A
            if (r0 == 0) goto L_0x0009
            int r0 = r6.k2()
            goto L_0x000d
        L_0x0009:
            int r0 = r6.j2()
        L_0x000d:
            r1 = 8
            if (r9 != r1) goto L_0x001a
            if (r7 >= r8) goto L_0x0016
            int r2 = r8 + 1
            goto L_0x001c
        L_0x0016:
            int r2 = r7 + 1
            r3 = r8
            goto L_0x001d
        L_0x001a:
            int r2 = r7 + r8
        L_0x001c:
            r3 = r7
        L_0x001d:
            androidx.recyclerview.widget.StaggeredGridLayoutManager$d r4 = r6.E
            r4.h(r3)
            r4 = 1
            if (r9 == r4) goto L_0x003c
            r5 = 2
            if (r9 == r5) goto L_0x0036
            if (r9 == r1) goto L_0x002b
            goto L_0x0041
        L_0x002b:
            androidx.recyclerview.widget.StaggeredGridLayoutManager$d r9 = r6.E
            r9.k(r7, r4)
            androidx.recyclerview.widget.StaggeredGridLayoutManager$d r7 = r6.E
            r7.j(r8, r4)
            goto L_0x0041
        L_0x0036:
            androidx.recyclerview.widget.StaggeredGridLayoutManager$d r9 = r6.E
            r9.k(r7, r8)
            goto L_0x0041
        L_0x003c:
            androidx.recyclerview.widget.StaggeredGridLayoutManager$d r9 = r6.E
            r9.j(r7, r8)
        L_0x0041:
            if (r2 > r0) goto L_0x0044
            return
        L_0x0044:
            boolean r7 = r6.A
            if (r7 == 0) goto L_0x004d
            int r7 = r6.j2()
            goto L_0x0051
        L_0x004d:
            int r7 = r6.k2()
        L_0x0051:
            if (r3 > r7) goto L_0x0056
            r6.t1()
        L_0x0056:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.StaggeredGridLayoutManager.q2(int, int, int):void");
    }

    private void u2(View view, int i, int i2, boolean z2) {
        j(view, this.K);
        c cVar = (c) view.getLayoutParams();
        int i3 = cVar.leftMargin;
        Rect rect = this.K;
        int R2 = R2(i, i3 + rect.left, cVar.rightMargin + rect.right);
        int i4 = cVar.topMargin;
        Rect rect2 = this.K;
        int R22 = R2(i2, i4 + rect2.top, cVar.bottomMargin + rect2.bottom);
        if (z2 ? H1(view, R2, R22, cVar) : F1(view, R2, R22, cVar)) {
            view.measure(R2, R22);
        }
    }

    private void v2(View view, c cVar, boolean z2) {
        int i;
        int i2;
        if (cVar.f) {
            if (this.w == 1) {
                i2 = this.J;
            } else {
                u2(view, RecyclerView.o.K(o0(), p0(), e0() + f0(), cVar.width, true), this.J, z2);
                return;
            }
        } else if (this.w == 1) {
            i2 = RecyclerView.o.K(this.x, p0(), 0, cVar.width, false);
        } else {
            i2 = RecyclerView.o.K(o0(), p0(), e0() + f0(), cVar.width, true);
            i = RecyclerView.o.K(this.x, X(), 0, cVar.height, false);
            u2(view, i2, i, z2);
        }
        i = RecyclerView.o.K(W(), X(), g0() + d0(), cVar.height, true);
        u2(view, i2, i, z2);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:83:0x014b, code lost:
        if (S1() != false) goto L_0x014f;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void w2(androidx.recyclerview.widget.RecyclerView.v r9, androidx.recyclerview.widget.RecyclerView.a0 r10, boolean r11) {
        /*
            r8 = this;
            androidx.recyclerview.widget.StaggeredGridLayoutManager$b r0 = r8.L
            androidx.recyclerview.widget.StaggeredGridLayoutManager$e r1 = r8.I
            r2 = -1
            if (r1 != 0) goto L_0x000b
            int r1 = r8.C
            if (r1 == r2) goto L_0x0018
        L_0x000b:
            int r1 = r10.b()
            if (r1 != 0) goto L_0x0018
            r8.k1(r9)
            r0.c()
            return
        L_0x0018:
            boolean r1 = r0.e
            r3 = 0
            r4 = 1
            if (r1 == 0) goto L_0x0029
            int r1 = r8.C
            if (r1 != r2) goto L_0x0029
            androidx.recyclerview.widget.StaggeredGridLayoutManager$e r1 = r8.I
            if (r1 == 0) goto L_0x0027
            goto L_0x0029
        L_0x0027:
            r1 = 0
            goto L_0x002a
        L_0x0029:
            r1 = 1
        L_0x002a:
            if (r1 == 0) goto L_0x0043
            r0.c()
            androidx.recyclerview.widget.StaggeredGridLayoutManager$e r5 = r8.I
            if (r5 == 0) goto L_0x0037
            r8.N1(r0)
            goto L_0x003e
        L_0x0037:
            r8.E2()
            boolean r5 = r8.A
            r0.f915c = r5
        L_0x003e:
            r8.N2(r10, r0)
            r0.e = r4
        L_0x0043:
            androidx.recyclerview.widget.StaggeredGridLayoutManager$e r5 = r8.I
            if (r5 != 0) goto L_0x0060
            int r5 = r8.C
            if (r5 != r2) goto L_0x0060
            boolean r5 = r0.f915c
            boolean r6 = r8.G
            if (r5 != r6) goto L_0x0059
            boolean r5 = r8.t2()
            boolean r6 = r8.H
            if (r5 == r6) goto L_0x0060
        L_0x0059:
            androidx.recyclerview.widget.StaggeredGridLayoutManager$d r5 = r8.E
            r5.b()
            r0.f916d = r4
        L_0x0060:
            int r5 = r8.J()
            if (r5 <= 0) goto L_0x00c9
            androidx.recyclerview.widget.StaggeredGridLayoutManager$e r5 = r8.I
            if (r5 == 0) goto L_0x006e
            int r5 = r5.f924d
            if (r5 >= r4) goto L_0x00c9
        L_0x006e:
            boolean r5 = r0.f916d
            if (r5 == 0) goto L_0x008e
            r1 = 0
        L_0x0073:
            int r5 = r8.s
            if (r1 >= r5) goto L_0x00c9
            androidx.recyclerview.widget.StaggeredGridLayoutManager$f[] r5 = r8.t
            r5 = r5[r1]
            r5.e()
            int r5 = r0.f914b
            r6 = -2147483648(0xffffffff80000000, float:-0.0)
            if (r5 == r6) goto L_0x008b
            androidx.recyclerview.widget.StaggeredGridLayoutManager$f[] r6 = r8.t
            r6 = r6[r1]
            r6.v(r5)
        L_0x008b:
            int r1 = r1 + 1
            goto L_0x0073
        L_0x008e:
            if (r1 != 0) goto L_0x00af
            androidx.recyclerview.widget.StaggeredGridLayoutManager$b r1 = r8.L
            int[] r1 = r1.f
            if (r1 != 0) goto L_0x0097
            goto L_0x00af
        L_0x0097:
            r1 = 0
        L_0x0098:
            int r5 = r8.s
            if (r1 >= r5) goto L_0x00c9
            androidx.recyclerview.widget.StaggeredGridLayoutManager$f[] r5 = r8.t
            r5 = r5[r1]
            r5.e()
            androidx.recyclerview.widget.StaggeredGridLayoutManager$b r6 = r8.L
            int[] r6 = r6.f
            r6 = r6[r1]
            r5.v(r6)
            int r1 = r1 + 1
            goto L_0x0098
        L_0x00af:
            r1 = 0
        L_0x00b0:
            int r5 = r8.s
            if (r1 >= r5) goto L_0x00c2
            androidx.recyclerview.widget.StaggeredGridLayoutManager$f[] r5 = r8.t
            r5 = r5[r1]
            boolean r6 = r8.A
            int r7 = r0.f914b
            r5.b(r6, r7)
            int r1 = r1 + 1
            goto L_0x00b0
        L_0x00c2:
            androidx.recyclerview.widget.StaggeredGridLayoutManager$b r1 = r8.L
            androidx.recyclerview.widget.StaggeredGridLayoutManager$f[] r5 = r8.t
            r1.d(r5)
        L_0x00c9:
            r8.w(r9)
            androidx.recyclerview.widget.i r1 = r8.y
            r1.f1017a = r3
            r8.M = r3
            androidx.recyclerview.widget.n r1 = r8.v
            int r1 = r1.n()
            r8.P2(r1)
            int r1 = r0.f913a
            r8.O2(r1, r10)
            boolean r1 = r0.f915c
            if (r1 == 0) goto L_0x00f0
            r8.G2(r2)
            androidx.recyclerview.widget.i r1 = r8.y
            r8.b2(r9, r1, r10)
            r8.G2(r4)
            goto L_0x00fb
        L_0x00f0:
            r8.G2(r4)
            androidx.recyclerview.widget.i r1 = r8.y
            r8.b2(r9, r1, r10)
            r8.G2(r2)
        L_0x00fb:
            androidx.recyclerview.widget.i r1 = r8.y
            int r2 = r0.f913a
            int r5 = r1.f1020d
            int r2 = r2 + r5
            r1.f1019c = r2
            r8.b2(r9, r1, r10)
            r8.D2()
            int r1 = r8.J()
            if (r1 <= 0) goto L_0x0121
            boolean r1 = r8.A
            if (r1 == 0) goto L_0x011b
            r8.h2(r9, r10, r4)
            r8.i2(r9, r10, r3)
            goto L_0x0121
        L_0x011b:
            r8.i2(r9, r10, r4)
            r8.h2(r9, r10, r3)
        L_0x0121:
            if (r11 == 0) goto L_0x014e
            boolean r11 = r10.e()
            if (r11 != 0) goto L_0x014e
            int r11 = r8.F
            if (r11 == 0) goto L_0x013f
            int r11 = r8.J()
            if (r11 <= 0) goto L_0x013f
            boolean r11 = r8.M
            if (r11 != 0) goto L_0x013d
            android.view.View r11 = r8.r2()
            if (r11 == 0) goto L_0x013f
        L_0x013d:
            r11 = 1
            goto L_0x0140
        L_0x013f:
            r11 = 0
        L_0x0140:
            if (r11 == 0) goto L_0x014e
            java.lang.Runnable r11 = r8.P
            r8.o1(r11)
            boolean r11 = r8.S1()
            if (r11 == 0) goto L_0x014e
            goto L_0x014f
        L_0x014e:
            r4 = 0
        L_0x014f:
            boolean r11 = r10.e()
            if (r11 == 0) goto L_0x015a
            androidx.recyclerview.widget.StaggeredGridLayoutManager$b r11 = r8.L
            r11.c()
        L_0x015a:
            boolean r11 = r0.f915c
            r8.G = r11
            boolean r11 = r8.t2()
            r8.H = r11
            if (r4 == 0) goto L_0x016e
            androidx.recyclerview.widget.StaggeredGridLayoutManager$b r11 = r8.L
            r11.c()
            r8.w2(r9, r10, r3)
        L_0x016e:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.StaggeredGridLayoutManager.w2(androidx.recyclerview.widget.RecyclerView$v, androidx.recyclerview.widget.RecyclerView$a0, boolean):void");
    }

    private boolean x2(int i) {
        if (this.w == 0) {
            return (i == -1) != this.A;
        }
        return ((i == -1) == this.A) == t2();
    }

    private void z2(View view) {
        for (int i = this.s - 1; i >= 0; i--) {
            this.t[i].u(view);
        }
    }

    public void C0(int i) {
        super.C0(i);
        for (int i2 = 0; i2 < this.s; i2++) {
            this.t[i2].r(i);
        }
    }

    public void C1(Rect rect, int i, int i2) {
        int i3;
        int i4;
        int e0 = e0() + f0();
        int g0 = g0() + d0();
        if (this.w == 1) {
            i4 = RecyclerView.o.n(i2, rect.height() + g0, b0());
            i3 = RecyclerView.o.n(i, (this.x * this.s) + e0, c0());
        } else {
            i3 = RecyclerView.o.n(i, rect.width() + e0, c0());
            i4 = RecyclerView.o.n(i2, (this.x * this.s) + g0, b0());
        }
        B1(i3, i4);
    }

    public RecyclerView.p D() {
        return this.w == 0 ? new c(-2, -1) : new c(-1, -2);
    }

    public void D0(int i) {
        super.D0(i);
        for (int i2 = 0; i2 < this.s; i2++) {
            this.t[i2].r(i);
        }
    }

    public RecyclerView.p E(Context context, AttributeSet attributeSet) {
        return new c(context, attributeSet);
    }

    public RecyclerView.p F(ViewGroup.LayoutParams layoutParams) {
        return layoutParams instanceof ViewGroup.MarginLayoutParams ? new c((ViewGroup.MarginLayoutParams) layoutParams) : new c(layoutParams);
    }

    /* access modifiers changed from: package-private */
    public int F2(int i, RecyclerView.v vVar, RecyclerView.a0 a0Var) {
        if (J() == 0 || i == 0) {
            return 0;
        }
        y2(i, a0Var);
        int b2 = b2(vVar, this.y, a0Var);
        if (this.y.f1018b >= b2) {
            i = i < 0 ? -b2 : b2;
        }
        this.u.r(-i);
        this.G = this.A;
        i iVar = this.y;
        iVar.f1018b = 0;
        A2(vVar, iVar);
        return i;
    }

    public void H2(int i) {
        if (i == 0 || i == 1) {
            g((String) null);
            if (i != this.w) {
                this.w = i;
                n nVar = this.u;
                this.u = this.v;
                this.v = nVar;
                t1();
                return;
            }
            return;
        }
        throw new IllegalArgumentException("invalid orientation.");
    }

    public void I0(RecyclerView recyclerView, RecyclerView.v vVar) {
        super.I0(recyclerView, vVar);
        o1(this.P);
        for (int i = 0; i < this.s; i++) {
            this.t[i].e();
        }
        recyclerView.requestLayout();
    }

    public void I1(RecyclerView recyclerView, RecyclerView.a0 a0Var, int i) {
        j jVar = new j(recyclerView.getContext());
        jVar.p(i);
        J1(jVar);
    }

    public void I2(boolean z2) {
        g((String) null);
        e eVar = this.I;
        if (!(eVar == null || eVar.i == z2)) {
            eVar.i = z2;
        }
        this.z = z2;
        t1();
    }

    public View J0(View view, int i, RecyclerView.v vVar, RecyclerView.a0 a0Var) {
        View B2;
        View m;
        if (J() == 0 || (B2 = B(view)) == null) {
            return null;
        }
        E2();
        int X1 = X1(i);
        if (X1 == Integer.MIN_VALUE) {
            return null;
        }
        c cVar = (c) B2.getLayoutParams();
        boolean z2 = cVar.f;
        f fVar = cVar.e;
        int k2 = X1 == 1 ? k2() : j2();
        O2(k2, a0Var);
        G2(X1);
        i iVar = this.y;
        iVar.f1019c = iVar.f1020d + k2;
        iVar.f1018b = (int) (((float) this.u.n()) * 0.33333334f);
        i iVar2 = this.y;
        iVar2.h = true;
        iVar2.f1017a = false;
        b2(vVar, iVar2, a0Var);
        this.G = this.A;
        if (!z2 && (m = fVar.m(k2, X1)) != null && m != B2) {
            return m;
        }
        if (x2(X1)) {
            for (int i2 = this.s - 1; i2 >= 0; i2--) {
                View m2 = this.t[i2].m(k2, X1);
                if (m2 != null && m2 != B2) {
                    return m2;
                }
            }
        } else {
            for (int i3 = 0; i3 < this.s; i3++) {
                View m3 = this.t[i3].m(k2, X1);
                if (m3 != null && m3 != B2) {
                    return m3;
                }
            }
        }
        boolean z3 = (this.z ^ true) == (X1 == -1);
        if (!z2) {
            View C2 = C(z3 ? fVar.f() : fVar.g());
            if (!(C2 == null || C2 == B2)) {
                return C2;
            }
        }
        if (x2(X1)) {
            for (int i4 = this.s - 1; i4 >= 0; i4--) {
                if (i4 != fVar.e) {
                    f[] fVarArr = this.t;
                    View C3 = C(z3 ? fVarArr[i4].f() : fVarArr[i4].g());
                    if (!(C3 == null || C3 == B2)) {
                        return C3;
                    }
                }
            }
        } else {
            for (int i5 = 0; i5 < this.s; i5++) {
                f[] fVarArr2 = this.t;
                View C4 = C(z3 ? fVarArr2[i5].f() : fVarArr2[i5].g());
                if (C4 != null && C4 != B2) {
                    return C4;
                }
            }
        }
        return null;
    }

    public void J2(int i) {
        g((String) null);
        if (i != this.s) {
            s2();
            this.s = i;
            this.B = new BitSet(this.s);
            this.t = new f[this.s];
            for (int i2 = 0; i2 < this.s; i2++) {
                this.t[i2] = new f(i2);
            }
            t1();
        }
    }

    public void K0(AccessibilityEvent accessibilityEvent) {
        super.K0(accessibilityEvent);
        if (J() > 0) {
            View e2 = e2(false);
            View d2 = d2(false);
            if (e2 != null && d2 != null) {
                int h0 = h0(e2);
                int h02 = h0(d2);
                if (h0 < h02) {
                    accessibilityEvent.setFromIndex(h0);
                    accessibilityEvent.setToIndex(h02);
                    return;
                }
                accessibilityEvent.setFromIndex(h02);
                accessibilityEvent.setToIndex(h0);
            }
        }
    }

    public boolean L1() {
        return this.I == null;
    }

    /* access modifiers changed from: package-private */
    public boolean M2(RecyclerView.a0 a0Var, b bVar) {
        int i;
        int i2;
        int i3;
        boolean z2 = false;
        if (!a0Var.e() && (i = this.C) != -1) {
            if (i < 0 || i >= a0Var.b()) {
                this.C = -1;
                this.D = RecyclerView.UNDEFINED_DURATION;
            } else {
                e eVar = this.I;
                if (eVar == null || eVar.f922b == -1 || eVar.f924d < 1) {
                    View C2 = C(this.C);
                    if (C2 != null) {
                        bVar.f913a = this.A ? k2() : j2();
                        if (this.D != Integer.MIN_VALUE) {
                            if (bVar.f915c) {
                                i3 = this.u.i() - this.D;
                                i2 = this.u.d(C2);
                            } else {
                                i3 = this.u.m() + this.D;
                                i2 = this.u.g(C2);
                            }
                            bVar.f914b = i3 - i2;
                            return true;
                        } else if (this.u.e(C2) > this.u.n()) {
                            bVar.f914b = bVar.f915c ? this.u.i() : this.u.m();
                            return true;
                        } else {
                            int g = this.u.g(C2) - this.u.m();
                            if (g < 0) {
                                bVar.f914b = -g;
                                return true;
                            }
                            int i4 = this.u.i() - this.u.d(C2);
                            if (i4 < 0) {
                                bVar.f914b = i4;
                                return true;
                            }
                            bVar.f914b = RecyclerView.UNDEFINED_DURATION;
                        }
                    } else {
                        int i5 = this.C;
                        bVar.f913a = i5;
                        int i6 = this.D;
                        if (i6 == Integer.MIN_VALUE) {
                            if (R1(i5) == 1) {
                                z2 = true;
                            }
                            bVar.f915c = z2;
                            bVar.a();
                        } else {
                            bVar.b(i6);
                        }
                        bVar.f916d = true;
                    }
                } else {
                    bVar.f914b = RecyclerView.UNDEFINED_DURATION;
                    bVar.f913a = this.C;
                }
                return true;
            }
        }
        return false;
    }

    public int N(RecyclerView.v vVar, RecyclerView.a0 a0Var) {
        return this.w == 1 ? this.s : super.N(vVar, a0Var);
    }

    /* access modifiers changed from: package-private */
    public void N2(RecyclerView.a0 a0Var, b bVar) {
        if (!M2(a0Var, bVar) && !L2(a0Var, bVar)) {
            bVar.a();
            bVar.f913a = 0;
        }
    }

    /* access modifiers changed from: package-private */
    public boolean O1() {
        int l = this.t[0].l(RecyclerView.UNDEFINED_DURATION);
        for (int i = 1; i < this.s; i++) {
            if (this.t[i].l(RecyclerView.UNDEFINED_DURATION) != l) {
                return false;
            }
        }
        return true;
    }

    public void P0(RecyclerView.v vVar, RecyclerView.a0 a0Var, View view, b.f.l.b0.c cVar) {
        int i;
        int i2;
        int i3;
        int i4;
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        if (!(layoutParams instanceof c)) {
            super.O0(view, cVar);
            return;
        }
        c cVar2 = (c) layoutParams;
        if (this.w == 0) {
            i4 = cVar2.e();
            i3 = cVar2.f ? this.s : 1;
            i2 = -1;
            i = -1;
        } else {
            i4 = -1;
            i3 = -1;
            i2 = cVar2.e();
            i = cVar2.f ? this.s : 1;
        }
        cVar.a0(c.C0044c.f(i4, i3, i2, i, false, false));
    }

    /* access modifiers changed from: package-private */
    public boolean P1() {
        int p = this.t[0].p(RecyclerView.UNDEFINED_DURATION);
        for (int i = 1; i < this.s; i++) {
            if (this.t[i].p(RecyclerView.UNDEFINED_DURATION) != p) {
                return false;
            }
        }
        return true;
    }

    /* access modifiers changed from: package-private */
    public void P2(int i) {
        this.x = i / this.s;
        this.J = View.MeasureSpec.makeMeasureSpec(i, this.v.k());
    }

    public void R0(RecyclerView recyclerView, int i, int i2) {
        q2(i, i2, 1);
    }

    public void S0(RecyclerView recyclerView) {
        this.E.b();
        t1();
    }

    /* access modifiers changed from: package-private */
    public boolean S1() {
        int i;
        int i2;
        if (J() == 0 || this.F == 0 || !r0()) {
            return false;
        }
        if (this.A) {
            i2 = k2();
            i = j2();
        } else {
            i2 = j2();
            i = k2();
        }
        if (i2 == 0 && r2() != null) {
            this.E.b();
        } else if (!this.M) {
            return false;
        } else {
            int i3 = this.A ? -1 : 1;
            int i4 = i + 1;
            d.a e2 = this.E.e(i2, i4, i3, true);
            if (e2 == null) {
                this.M = false;
                this.E.d(i4);
                return false;
            }
            d.a e3 = this.E.e(i2, e2.f919b, i3 * -1, true);
            if (e3 == null) {
                this.E.d(e2.f919b);
            } else {
                this.E.d(e3.f919b + 1);
            }
        }
        u1();
        t1();
        return true;
    }

    public void T0(RecyclerView recyclerView, int i, int i2, int i3) {
        q2(i, i2, 8);
    }

    public void U0(RecyclerView recyclerView, int i, int i2) {
        q2(i, i2, 2);
    }

    public void W0(RecyclerView recyclerView, int i, int i2, Object obj) {
        q2(i, i2, 4);
    }

    public void X0(RecyclerView.v vVar, RecyclerView.a0 a0Var) {
        w2(vVar, a0Var, true);
    }

    public void Y0(RecyclerView.a0 a0Var) {
        super.Y0(a0Var);
        this.C = -1;
        this.D = RecyclerView.UNDEFINED_DURATION;
        this.I = null;
        this.L.c();
    }

    public PointF a(int i) {
        int R1 = R1(i);
        PointF pointF = new PointF();
        if (R1 == 0) {
            return null;
        }
        if (this.w == 0) {
            pointF.x = (float) R1;
            pointF.y = 0.0f;
        } else {
            pointF.x = 0.0f;
            pointF.y = (float) R1;
        }
        return pointF;
    }

    public void c1(Parcelable parcelable) {
        if (parcelable instanceof e) {
            this.I = (e) parcelable;
            t1();
        }
    }

    public Parcelable d1() {
        int i;
        int i2;
        int[] iArr;
        if (this.I != null) {
            return new e(this.I);
        }
        e eVar = new e();
        eVar.i = this.z;
        eVar.j = this.G;
        eVar.k = this.H;
        d dVar = this.E;
        if (dVar == null || (iArr = dVar.f917a) == null) {
            eVar.f = 0;
        } else {
            eVar.g = iArr;
            eVar.f = iArr.length;
            eVar.h = dVar.f918b;
        }
        if (J() > 0) {
            eVar.f922b = this.G ? k2() : j2();
            eVar.f923c = f2();
            int i3 = this.s;
            eVar.f924d = i3;
            eVar.e = new int[i3];
            for (int i4 = 0; i4 < this.s; i4++) {
                if (this.G) {
                    i = this.t[i4].l(RecyclerView.UNDEFINED_DURATION);
                    if (i != Integer.MIN_VALUE) {
                        i2 = this.u.i();
                    } else {
                        eVar.e[i4] = i;
                    }
                } else {
                    i = this.t[i4].p(RecyclerView.UNDEFINED_DURATION);
                    if (i != Integer.MIN_VALUE) {
                        i2 = this.u.m();
                    } else {
                        eVar.e[i4] = i;
                    }
                }
                i -= i2;
                eVar.e[i4] = i;
            }
        } else {
            eVar.f922b = -1;
            eVar.f923c = -1;
            eVar.f924d = 0;
        }
        return eVar;
    }

    /* access modifiers changed from: package-private */
    public View d2(boolean z2) {
        int m = this.u.m();
        int i = this.u.i();
        View view = null;
        for (int J2 = J() - 1; J2 >= 0; J2--) {
            View I2 = I(J2);
            int g = this.u.g(I2);
            int d2 = this.u.d(I2);
            if (d2 > m && g < i) {
                if (d2 <= i || !z2) {
                    return I2;
                }
                if (view == null) {
                    view = I2;
                }
            }
        }
        return view;
    }

    public void e1(int i) {
        if (i == 0) {
            S1();
        }
    }

    /* access modifiers changed from: package-private */
    public View e2(boolean z2) {
        int m = this.u.m();
        int i = this.u.i();
        int J2 = J();
        View view = null;
        for (int i2 = 0; i2 < J2; i2++) {
            View I2 = I(i2);
            int g = this.u.g(I2);
            if (this.u.d(I2) > m && g < i) {
                if (g >= m || !z2) {
                    return I2;
                }
                if (view == null) {
                    view = I2;
                }
            }
        }
        return view;
    }

    /* access modifiers changed from: package-private */
    public int f2() {
        View d2 = this.A ? d2(true) : e2(true);
        if (d2 == null) {
            return -1;
        }
        return h0(d2);
    }

    public void g(String str) {
        if (this.I == null) {
            super.g(str);
        }
    }

    /* access modifiers changed from: package-private */
    public int j2() {
        if (J() == 0) {
            return 0;
        }
        return h0(I(0));
    }

    public boolean k() {
        return this.w == 0;
    }

    public int k0(RecyclerView.v vVar, RecyclerView.a0 a0Var) {
        return this.w == 0 ? this.s : super.k0(vVar, a0Var);
    }

    /* access modifiers changed from: package-private */
    public int k2() {
        int J2 = J();
        if (J2 == 0) {
            return 0;
        }
        return h0(I(J2 - 1));
    }

    public boolean l() {
        return this.w == 1;
    }

    public boolean m(RecyclerView.p pVar) {
        return pVar instanceof c;
    }

    public void o(int i, int i2, RecyclerView.a0 a0Var, RecyclerView.o.c cVar) {
        int i3;
        int i4;
        if (this.w != 0) {
            i = i2;
        }
        if (J() != 0 && i != 0) {
            y2(i, a0Var);
            int[] iArr = this.O;
            if (iArr == null || iArr.length < this.s) {
                this.O = new int[this.s];
            }
            int i5 = 0;
            for (int i6 = 0; i6 < this.s; i6++) {
                i iVar = this.y;
                if (iVar.f1020d == -1) {
                    i4 = iVar.f;
                    i3 = this.t[i6].p(i4);
                } else {
                    i4 = this.t[i6].l(iVar.g);
                    i3 = this.y.g;
                }
                int i7 = i4 - i3;
                if (i7 >= 0) {
                    this.O[i5] = i7;
                    i5++;
                }
            }
            Arrays.sort(this.O, 0, i5);
            for (int i8 = 0; i8 < i5 && this.y.a(a0Var); i8++) {
                cVar.a(this.y.f1019c, this.O[i8]);
                i iVar2 = this.y;
                iVar2.f1019c += iVar2.f1020d;
            }
        }
    }

    public int q(RecyclerView.a0 a0Var) {
        return U1(a0Var);
    }

    public int r(RecyclerView.a0 a0Var) {
        return V1(a0Var);
    }

    /* access modifiers changed from: package-private */
    /* JADX WARNING: Code restructure failed: missing block: B:28:0x0074, code lost:
        if (r10 == r11) goto L_0x0088;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:32:0x0086, code lost:
        if (r10 == r11) goto L_0x0088;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:34:0x008a, code lost:
        r10 = false;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public android.view.View r2() {
        /*
            r12 = this;
            int r0 = r12.J()
            r1 = 1
            int r0 = r0 - r1
            java.util.BitSet r2 = new java.util.BitSet
            int r3 = r12.s
            r2.<init>(r3)
            int r3 = r12.s
            r4 = 0
            r2.set(r4, r3, r1)
            int r3 = r12.w
            r5 = -1
            if (r3 != r1) goto L_0x0020
            boolean r3 = r12.t2()
            if (r3 == 0) goto L_0x0020
            r3 = 1
            goto L_0x0021
        L_0x0020:
            r3 = -1
        L_0x0021:
            boolean r6 = r12.A
            if (r6 == 0) goto L_0x0027
            r6 = -1
            goto L_0x002b
        L_0x0027:
            int r0 = r0 + 1
            r6 = r0
            r0 = 0
        L_0x002b:
            if (r0 >= r6) goto L_0x002e
            r5 = 1
        L_0x002e:
            if (r0 == r6) goto L_0x00ab
            android.view.View r7 = r12.I(r0)
            android.view.ViewGroup$LayoutParams r8 = r7.getLayoutParams()
            androidx.recyclerview.widget.StaggeredGridLayoutManager$c r8 = (androidx.recyclerview.widget.StaggeredGridLayoutManager.c) r8
            androidx.recyclerview.widget.StaggeredGridLayoutManager$f r9 = r8.e
            int r9 = r9.e
            boolean r9 = r2.get(r9)
            if (r9 == 0) goto L_0x0054
            androidx.recyclerview.widget.StaggeredGridLayoutManager$f r9 = r8.e
            boolean r9 = r12.T1(r9)
            if (r9 == 0) goto L_0x004d
            return r7
        L_0x004d:
            androidx.recyclerview.widget.StaggeredGridLayoutManager$f r9 = r8.e
            int r9 = r9.e
            r2.clear(r9)
        L_0x0054:
            boolean r9 = r8.f
            if (r9 == 0) goto L_0x0059
            goto L_0x00a9
        L_0x0059:
            int r9 = r0 + r5
            if (r9 == r6) goto L_0x00a9
            android.view.View r9 = r12.I(r9)
            boolean r10 = r12.A
            if (r10 == 0) goto L_0x0077
            androidx.recyclerview.widget.n r10 = r12.u
            int r10 = r10.d(r7)
            androidx.recyclerview.widget.n r11 = r12.u
            int r11 = r11.d(r9)
            if (r10 >= r11) goto L_0x0074
            return r7
        L_0x0074:
            if (r10 != r11) goto L_0x008a
            goto L_0x0088
        L_0x0077:
            androidx.recyclerview.widget.n r10 = r12.u
            int r10 = r10.g(r7)
            androidx.recyclerview.widget.n r11 = r12.u
            int r11 = r11.g(r9)
            if (r10 <= r11) goto L_0x0086
            return r7
        L_0x0086:
            if (r10 != r11) goto L_0x008a
        L_0x0088:
            r10 = 1
            goto L_0x008b
        L_0x008a:
            r10 = 0
        L_0x008b:
            if (r10 == 0) goto L_0x00a9
            android.view.ViewGroup$LayoutParams r9 = r9.getLayoutParams()
            androidx.recyclerview.widget.StaggeredGridLayoutManager$c r9 = (androidx.recyclerview.widget.StaggeredGridLayoutManager.c) r9
            androidx.recyclerview.widget.StaggeredGridLayoutManager$f r8 = r8.e
            int r8 = r8.e
            androidx.recyclerview.widget.StaggeredGridLayoutManager$f r9 = r9.e
            int r9 = r9.e
            int r8 = r8 - r9
            if (r8 >= 0) goto L_0x00a0
            r8 = 1
            goto L_0x00a1
        L_0x00a0:
            r8 = 0
        L_0x00a1:
            if (r3 >= 0) goto L_0x00a5
            r9 = 1
            goto L_0x00a6
        L_0x00a5:
            r9 = 0
        L_0x00a6:
            if (r8 == r9) goto L_0x00a9
            return r7
        L_0x00a9:
            int r0 = r0 + r5
            goto L_0x002e
        L_0x00ab:
            r0 = 0
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.StaggeredGridLayoutManager.r2():android.view.View");
    }

    public int s(RecyclerView.a0 a0Var) {
        return W1(a0Var);
    }

    public boolean s0() {
        return this.F != 0;
    }

    public void s2() {
        this.E.b();
        t1();
    }

    public int t(RecyclerView.a0 a0Var) {
        return U1(a0Var);
    }

    /* access modifiers changed from: package-private */
    public boolean t2() {
        return Z() == 1;
    }

    public int u(RecyclerView.a0 a0Var) {
        return V1(a0Var);
    }

    public int v(RecyclerView.a0 a0Var) {
        return W1(a0Var);
    }

    public int w1(int i, RecyclerView.v vVar, RecyclerView.a0 a0Var) {
        return F2(i, vVar, a0Var);
    }

    public void x1(int i) {
        e eVar = this.I;
        if (!(eVar == null || eVar.f922b == i)) {
            eVar.j();
        }
        this.C = i;
        this.D = RecyclerView.UNDEFINED_DURATION;
        t1();
    }

    public int y1(int i, RecyclerView.v vVar, RecyclerView.a0 a0Var) {
        return F2(i, vVar, a0Var);
    }

    /* access modifiers changed from: package-private */
    public void y2(int i, RecyclerView.a0 a0Var) {
        int i2;
        int i3;
        if (i > 0) {
            i3 = k2();
            i2 = 1;
        } else {
            i3 = j2();
            i2 = -1;
        }
        this.y.f1017a = true;
        O2(i3, a0Var);
        G2(i2);
        i iVar = this.y;
        iVar.f1019c = i3 + iVar.f1020d;
        iVar.f1018b = Math.abs(i);
    }
}
